#include <iostream>
#include <string>
#include <sstream>

using namespace std;

int b[4], c[4], g[4];	//  due to the one-off bug of the indices
string s;

int main()
{
	while (getline(cin, s))
	{
		istringstream ss(s);
		for (int i = 1; i <= 3; i++) ss >> b[i] >> g[i] >> c[i];
			
		int result = 1 << 30;
		result = min(result, b[2]+b[3]+g[1]+g[2]+c[1]+c[3]);	// BCG		
		result = min(result, b[2]+b[3]+g[1]+g[3]+c[1]+c[2]);	// BGC
		result = min(result, b[1]+b[3]+g[1]+g[2]+c[2]+c[3]);	// CBG
		result = min(result, b[1]+b[2]+g[1]+g[3]+c[2]+c[3]);	// CGB
		result = min(result, b[1]+b[3]+g[2]+g[3]+c[1]+c[2]);	// GBC
		result = min(result, b[1]+b[2]+g[2]+g[3]+c[1]+c[3]);	// GCB
		
		if (result == b[2]+b[3]+g[1]+g[2]+c[1]+c[3]) cout << "BCG " << result << endl; else
		if (result == b[2]+b[3]+g[1]+g[3]+c[1]+c[2]) cout << "BGC " << result << endl; else
		if (result == b[1]+b[3]+g[1]+g[2]+c[2]+c[3]) cout << "CBG " << result << endl; else
		if (result == b[1]+b[2]+g[1]+g[3]+c[2]+c[3]) cout << "CGB " << result << endl; else
		if (result == b[1]+b[3]+g[2]+g[3]+c[1]+c[2]) cout << "GBC " << result << endl; else
		if (result == b[1]+b[2]+g[2]+g[3]+c[1]+c[3]) cout << "GCB " << result << endl; 	
	}
	return 0;
}
